/*
 * @lc app=leetcode.cn id=17 lang=golang
 *
 * [17] 电话号码的字母组合
 */

// @lc code=start
var phoneMap = map[int]string{
	'2': "abc",
	'3': "def",
	'4': "ghi",
	'5': "jkl",
	'6': "mno",
	'7': "pqrs",
	'8': "tuv",
	'9': "wxyz",
}

func letterCombinations(digits string) (ans []string) {
	if len(digits) == 0 {
		return
	}
	if len(digits) == 1 {
		for _, v := range phoneMap[int(digits[0])] {
			ans = append(ans, string(v))
		}
		return
	}
	for _, v := range phoneMap[int(digits[0])] {
		for _, v1 := range letterCombinations(digits[1:]) {
			ans = append(ans, string(v)+v1)
		}
	}
	return
}

// @lc code=end

